package it.unina.uninachi;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapterTabellone extends BaseAdapter {
    private Context mContext;
    private int risoluzione;

    public ImageAdapterTabellone(Context c, int r) {
        mContext = c;
        risoluzione = r;
    }
    
    
    public int getCount() {
        return TabelloneActivity.mThumbIds.length;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    //creo un nuovo ImageView per ogni elemento referenziato dall'adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  //inizializzazione attributi
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(risoluzione,risoluzione));
            imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
            imageView.setPadding(0, 0, 0, 0);
        } else {
            imageView = (ImageView) convertView;
        }

        imageView.setImageResource(TabelloneActivity.mThumbIds[position]);
        return imageView;
    }
}